<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<meta content="initial-scale=1.0,user-scalable=no,maximum-scale=1" media="(device-height: 568px)" name="viewport">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta content="telephone=no" name="format-detection">
<title>苗木通讯录</title>
<include file="Public/header"/>
</head>
<body >
	<div class="weui_msg">
		<form id="myform" method="get" action="http://{:C('DOMAIN')}/pay/example/jsapi2.php">
			<input type="hidden" name="id" value="{$userid}" />
			<div class="weui_icon_area" style="font-size:50px;color:#333;">
				<span id="manay">{$manay}</span><span style="font-size:18px;">元</span>
				<p class="weui_msg_desc">苗木通讯录会员年费</p>
			</div>
			<div class="weui_text_area">
				<!--<div class="weui_cells_title">表单</div>-->
				<div class="weui_cells weui_cells_form" style="width:120px;margin:0 auto;">
				<div class="weui_cell" style="border:1px solid #eee;height:20px;line-height:20px;">
					<!--
					<div class="weui_cell_hd">
					<label class="weui_label">邀请码</label>
					</div>
					-->
					<div class="weui_cell_bd weui_cell_primary" >
						<input class="weui_input" type="text" placeholder="邀请码" id="code" name="ecode" style="text-align:center;height:20px;line-height:20px;">
					</div>
				</div>
				</div>
				<p class="weui_msg_desc" style="color:red;">输入邀请码立减{$lj}元
					<i class="weui_icon_warn" id="msg" style="display:none;"></i>
				</p>
				<!--<h2 class="weui_msg_title">输入邀请码立减2元</h2>-->
			</div>
			<div class="weui_opr_area">
			<p class="weui_btn_area">
			<a href="javascript:;" class="weui_btn weui_btn_primary" id="submit">确定</a>
			<!--<a href="javascript:;" class="weui_btn weui_btn_primary" id="submit">没有邀请码直接支付</a>-->
			<a href="javascript:;" class="weui_btn weui_btn_default" onclick="window.location.href='{:U('Index/myself')}'">取消</a>
			</p>
			</div>
			<!--
			<div class="weui_extra_area">
			<a href="">查看详情</a>
			</div>
			-->
		</form>
	</div>
</body>
</html>
<script>
var x = 1;
$("#code").keyup(function(){
	$('#msg').show();
	var v = $(this).val();
	if(v.length == 4) {
		var url = '{:U('Index/code')}';
		var postdata = {code:v};
		$.post(url,postdata,function(data) {
				if(data == 1) {
					x = 1;
					$('#msg').removeClass('weui_icon_warn');
					$('#msg').addClass('weui_icon_success');
					var manay = {$manay}-{$lj};
					$('#manay').text(manay);
				} else {
					x = 2;
					$('#msg').removeClass('weui_icon_success');
					$('#msg').addClass('weui_icon_warn');
					$('#manay').text('{$manay}');
				}
		},'json');
	} else if(v.length == 0) {
		x = 1;
		$('#msg').hide();
		$('#manay').text('{$manay}');
	} else {
		x = 2;
		$('#msg').removeClass('weui_icon_success');
		$('#msg').addClass('weui_icon_warn');
		$('#manay').text('{$manay}');
	}
});

$('#submit').click(function() {
	if(x == 1) {
		$('#myform').submit();
	} else {
		alert('邀请码错误');
	}
});
</script>
